import type { App } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { createRouterGuard } from './guard'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name:'home',
      alias: '/home',
      component: () => import('@/views/home/Home.vue'),

    },

    {
      path:'/login',
      name:'login',
      component:() => import('@/views/login/Login.vue')
    },
    
    {
      path:'/register-account',
      name:'registerAccount',
      component:() => import('@/views/login/RegisterAccount.vue')
    },
    
    {
      path:'/find-password',
      name:'findPassword',
      component:() => import('@/views/login/FindPassword.vue')
    },
    
  
    {
      name: 'welcome',
      path: '/welcome',
      component: () => import('@/views/home/Welcome.vue'),
    },

    {
      name: 'roleSelect',
      path: '/role-select',
      component: () => import('@/views/home/roleSelect.vue'),
    },

    {
      name: 'mine',
      path: '/mine',
      component: () => import('@/views/mine/Mine.vue'),
    },
    {
      name: 'timeReview',
      path: '/time-review',
      component: () => import('@/views/mine/TimeReview.vue'),
    },

    {
      name: 'TodayStatus',
      path: '/today-status',
      component: () => import('@/views/mine/TodayStatus.vue'),
    },

    {
      name: 'myAchievement',
      path: '/my-cchievement',
      component: () => import('@/views/mine/myAchievement.vue'),
    },

    {
      name: 'toDoTasks',
      path: '/to-do-tasks',
      component: () => import('@/views/toDoTasks/ToDoTasks.vue'),
    },


    {
      name: 'settings',
      path: '/settings',
      component: () => import('@/views/settings/Settings.vue'),
    },

    {
      name:'thingsList',
      path: '/things-list',
      component: () => import('@/views/thingsList/ThingsList.vue'),
    },

    {
      name:'thingsDetail',
      path: '/things-detail',
      component: () => import('@/views/thingsList/ThingsDetail.vue'),
    },

    
    {
      name:'uploadFile',
      path:'/upload-file',
      component:()=>import('@/views/uploadFile.vue')
    },


    {
      name: 'error',
      path: '/error',
      component: () => import('@/views/error/Error.vue'),
    },
  ],
})

export default router

// 解决升级vite5.0之后，store中引入router导致的circular imports 热更新失效问题
window.router = router

export function setupRouter(app: App) {
  app.use(router)
  createRouterGuard(router)
}
